<?php
namespace app\admin\controller;

use app\admin\Model\Administrator as AdministratorModel;
use app\BaseController;
use app\admin\service\Tool;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\View;

//管理员
class Administrator extends BaseController
{
    /**
     * @return View
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function list(): View
    {
        if ($this->request->isPost()) {
            $param = $this->request->param();
            list($where, $order, $page, $limit) = Tool::buildParams($param);
            $admins = AdministratorModel::where($where);
            $list   = $admins->order($order)->page($page)->limit($limit)
                ->select();
            $count  = $admins->count();

            $this->page_return('获取成功', $list, $count);

        }

        return view('list');

    }
}
